export interface IStyleOption {
	tag: string
	style: Record<string, string>
}

export const getTitleWidth = (title: string, option?: IStyleOption): number => {
	const sp = document.createElement(option?.tag || 'span')
	sp.innerText = title
	if (option?.style) {
		Object.keys(option?.style).forEach((key: any) => {
			sp.style[key] = option?.style[key] as string
		})
	} else {
		sp.style.font = 'normal normal normal bolder 18px/18px 黑体'
	}
	sp.style.visibility = 'hidden'
	document.body.append(sp)
	const Info = sp.getBoundingClientRect()
	const spW = Info.width
	document.body.removeChild(sp)
	return spW
}